package Classroom1;

import java.io.*;
import java.net.InetAddress;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.Scanner;

public class Server {
    public static void main(String[] args) throws IOException {
        ServerSocket ss = new ServerSocket(10000);
        //监听
        Socket socket = ss.accept();
        //接受数据,获取输入流
        InputStream is = socket.getInputStream();
        System.setIn(is);
        Scanner sc = new Scanner(System.in);
        //BufferedReader br = new BufferedReader(new InputStreamReader(is));

        //读取
        String s = sc.nextLine();
        //获取客户端对象
        InetAddress address = socket.getInetAddress();
        System.out.print(address.getHostName()+" ");
        System.out.println(s);

        //回写数据给客户端
        PrintWriter pw = new PrintWriter(socket.getOutputStream(),true);
        pw.println("我不会");

        //释放
        socket.close();
        ss.close();
    }
}
